<%@page import="java.net.URLDecoder"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>易买网 - 首页</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="scripts/jquery-1.8.3.min.js"></script>
</head>
<body>
<div id="header" class="wrap">
	<div id="logo"><img src="images/logo.gif" /></div>
	<div class="help"><a href="/easyBuy170601/ShoppingCarInfoServlet" id="shoppingBag" class="shopping">购物车X件</a><a href="login.jsp">登录</a><a class="button" id="logout" href="javascript:void(0);">注销</a><a href="register.html">注册</a><a href="/easyBuy170601/ShowLeavingInfoServlet">留言</a><a href="manage/index.jsp">后台管理</a></div>
	<div class="navbar">
		<ul class="clearfix">
			<li class="current"><a href="#">首页</a></li>
			<li><a href="#">图书</a></li>
			<li><a href="#">百货</a></li>
			<li><a href="#">品牌</a></li>
			<li><a href="#">促销</a></li>
		</ul>
	</div>
</div>
<div id="childNav">
	<div class="wrap">
		<ul class="clearfix">
			<li class="first"><a href="#">音乐</a></li>
			<li><a href="#">影视</a></li>
			<li><a href="#">少儿</a></li>

			<li class="last"><a href="#">Investor Relations</a></li>
		</ul>
	</div>
</div>
<div id="position" class="wrap">
	您现在的位置：<a href="index.jsp">易买网</a> &gt; 购物车
</div>


<script type="text/javascript">
	$(function(){
			$("#del,#add").click(function(){
				var url=this.href;
				var args = {"time":new Date()};
				$.getJSON(url,args,function(data){
					$("#"+data.commodityID+"").text(data.quantityPurchased);
					$("#total").text("总价"+data.sumPrice);
					$("."+data.commodityID+"d").attr("href","/easyBuy170601/ShoppingCarInfoServlet_1?commodityID="+data.commodityID+"&quantityPurchased="+(data.quantityPurchased-1));
					$("."+data.commodityID+"a").attr("href","/easyBuy170601/ShoppingCarInfoServlet_1?commodityID="+data.commodityID+"&quantityPurchased="+(data.quantityPurchased+1));	
					})
					
					return false;
				})
		});
		
</script>



<div class="wrap">
	<div id="shopping">
			<table>
				<tr>
					<th>商品名称</th>
					<th>商品价格</th>
					<th>购买数量</th>
					<th>操作</th>
				</tr>
				<c:forEach items="${list}" var="emp" varStatus="status">
				<tr id="product_id_0">
				
					
					<td class="thumb"><img src="${emp.pictureSource}" /><a href="product-view.html">${emp.commodityName }</a></td>
					<td class="price" id="price_id_0">
						<span>￥${emp.commodityPrice}</span>
						<input type="hidden" value="${emp.commodityPrice}" />
						<input class="commodityID" type="hidden" value="${emp.commodityID}"/>
					</td>
					<td class="number" id="num">
                        <a href="/easyBuy170601/ShoppingCarInfoServlet_1?commodityID=${emp.commodityID}&quantityPurchased=${emp.quantityPurchased-1}" class="${emp.commodityID}d" id="del"><span name="del">-</span></a>
                        <span id="${emp.commodityID}">${emp.quantityPurchased}</span>
                        <a href="/easyBuy170601/ShoppingCarInfoServlet_1?commodityID=${emp.commodityID}&quantityPurchased=${emp.quantityPurchased+1}" class="${emp.commodityID}a" id="add"><span name="add">+</span></a>
					</td>
					<td class="delete"><a href="/easyBuy170601/ShoppingCarInfoServlet_2?commodityID=${emp.commodityID}">删除</a></td>
				</tr>
				
				</c:forEach>
			</table>
            <div class="total"><span id="total">总计：￥${list[0].sumPrice}</span></div>
			<div class="button"><a href="/easyBuy170601/ShoppingAddressServlet?commodityIDS=${sb}"><input type="submit" value="" /></a></div>
		
	</div>
	<script type="text/javascript">
		/* document.write("Cookie中记录的购物车商品ID："+ getCookie("product") + "，可以在动态页面中进行读取"); */
	</script>
</div>
<div id="footer">
	Copyright &copy; 2017云和学院 All Rights Reserved. 京ICP证1000001号</div>
</body>
</html>
